{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "stone-class",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/max-increase-to-keep-city-skyline\n",
    "\n",
    "\n",
    "Runtime: 12 ms, faster than 11.79% of C++ online submissions for Max Increase to Keep City Skyline.\n",
    "Memory Usage: 12 MB, less than 5.66% of C++ online submissions for Max Increase to Keep City Skyline.\n",
    "\n",
    "\n",
    "```cpp\n",
    "#include <vector>\n",
    "#include <algorithm>\n",
    "#include <map>\n",
    "#include <iostream>\n",
    "\n",
    "using namespace std;\n",
    "\n",
    "\n",
    "class Solution {\n",
    "public:\n",
    "    int maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {\n",
    "        //4:04\n",
    "        vector<int> row_skyline;\n",
    "        vector<int> column_skyline;\n",
    "        for(int i=0; i<grid.size(); i++) {\n",
    "            row_skyline.push_back(*max_element(grid[i].begin(), grid[i].end()));\n",
    "        }\n",
    "        for(int y=0; y<grid.size(); y++) {\n",
    "            vector<int> column;\n",
    "            for (int x=0; x<grid[0].size(); x++) {\n",
    "                column.push_back(grid[x][y]);\n",
    "            }\n",
    "            column_skyline.push_back(*max_element(column.begin(), column.end()));\n",
    "        }\n",
    "        int result = 0;\n",
    "        for (int y=0; y<grid.size(); y++) {\n",
    "            for (int x=0; x<grid[0].size(); x++) {\n",
    "                vector<int> arr {row_skyline[y], column_skyline[x]};\n",
    "                int target = *min_element(arr.begin(), arr.end());\n",
    "                result += target - grid[y][x];\n",
    "            }\n",
    "        }\n",
    "        return result;\n",
    "        //4:15\n",
    "    }\n",
    "};\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cooperative-steam",
   "metadata": {},
   "outputs": [],
   "source": [
    "    "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "C++17",
   "language": "C++17",
   "name": "xcpp17"
  },
  "language_info": {
   "codemirror_mode": "text/x-c++src",
   "file_extension": ".cpp",
   "mimetype": "text/x-c++src",
   "name": "c++",
   "version": "17"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
